﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IP.Core.IPData;
using IP.Core.IPUserService;
using BKIDS;
using BKIDS.CDBNames;
using BKIUS;
using IP.Core.IPCommon;


public partial class DanhMuc_F401_Thanh_vien_Vi_tri : System.Web.UI.Page
{
    #region Members
    US_DM_THANH_VIEN_VI_TRI m_us_dm_thanh_vien_vi_tri = new US_DM_THANH_VIEN_VI_TRI();
    DS_DM_THANH_VIEN_VI_TRI m_ds_dm_thanh_vien_vi_tri = new DS_DM_THANH_VIEN_VI_TRI();
    #endregion
    #region Private Methods
    private void load_data_2_grid()
    {
        m_us_dm_thanh_vien_vi_tri.FillDataset(m_ds_dm_thanh_vien_vi_tri);
        m_grv_tv_vt.DataSource = m_ds_dm_thanh_vien_vi_tri.DM_THANH_VIEN_VI_TRI;
        m_grv_tv_vt.DataBind();
    }
    private void load_data_2_combo_tv()
    {
        US_DM_THANH_VIEN v_us_thanh_vien = new US_DM_THANH_VIEN();
        DS_DM_THANH_VIEN v_ds_thanh_vien = new DS_DM_THANH_VIEN();

        v_us_thanh_vien.FillDataset(v_ds_thanh_vien);

        m_cbo_thanh_vien.DataTextField = DM_THANH_VIEN.TEN_THANH_VIEN;
        m_cbo_thanh_vien.DataValueField = DM_THANH_VIEN.ID;

        m_cbo_thanh_vien.DataSource = v_ds_thanh_vien.DM_THANH_VIEN;
        m_cbo_thanh_vien.DataBind();
    }
    private void load_data_2_combo_vitri()
    {
        US_CM_DM_TU_DIEN v_us_tu_dien = new US_CM_DM_TU_DIEN();
        DS_CM_DM_TU_DIEN v_ds_tu_dien = new DS_CM_DM_TU_DIEN();

        v_us_tu_dien.FillDataset(v_ds_tu_dien, " WHERE ID_LOAI_TU_DIEN=3");

        m_cbo_vi_tri.DataTextField = CM_DM_TU_DIEN.TEN;
        m_cbo_vi_tri.DataValueField = CM_DM_TU_DIEN.ID;

        m_cbo_vi_tri.DataSource = v_ds_tu_dien.CM_DM_TU_DIEN;
        m_cbo_vi_tri.DataBind();

    }
    private void load_data_2_combo_level()
    {
        US_CM_DM_TU_DIEN v_us_tu_dien = new US_CM_DM_TU_DIEN();
        DS_CM_DM_TU_DIEN v_ds_tu_dien = new DS_CM_DM_TU_DIEN();

        v_us_tu_dien.FillDataset(v_ds_tu_dien, " WHERE ID_LOAI_TU_DIEN=4");

        m_cbo_level.DataTextField = CM_DM_TU_DIEN.TEN_NGAN;
        m_cbo_level.DataValueField = CM_DM_TU_DIEN.ID;

        m_cbo_level.DataSource = v_ds_tu_dien.CM_DM_TU_DIEN;
        m_cbo_level.DataBind();
    }
    #endregion
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            load_data_2_grid();
        }
    }


    protected void Hien_form_Them_Sua_Thanh_vien_vi_tri()
    {
        lbl_thanh_vien.Visible = true;
        m_cbo_thanh_vien.Visible = true;
        lbl_vi_tri.Visible = true;
        m_cbo_vi_tri.Visible = true;
        lbl_level.Visible = true;
        m_cbo_level.Visible = true;
        m_btn_them.Visible = true;
    }
    protected void m_btn_them_moi_Click(object sender, EventArgs e)
    {
        load_data_2_combo_tv();
        load_data_2_combo_vitri();
        load_data_2_combo_level();
        lbl_tv_vi_tri.Text = "Thêm mới Thành viên - Vị trí";
        Hien_form_Them_Sua_Thanh_vien_vi_tri();
        m_btn_them_moi.Visible = false;
        m_grv_tv_vt.Visible = false;
    }
    // Load Tên thành viên lên combobox 

    #region Public Interfaces
    public string mapping_ten_thanh_vien_by_id(object ip_obj_id_thanh_vien)
    {
        US_DM_THANH_VIEN v_us_dm_thanh_vien = new US_DM_THANH_VIEN(CIPConvert.ToDecimal(ip_obj_id_thanh_vien));
        if (v_us_dm_thanh_vien.IsIDNull()) return "";
        return v_us_dm_thanh_vien.strHO_VA_TEN_DEM + v_us_dm_thanh_vien.strTEN_THANH_VIEN;
    }
    public string mapping_vi_tri_by_id(object ip_obj_id_vi_tri)
    {
        US_CM_DM_TU_DIEN v_us_dm_vi_tri = new US_CM_DM_TU_DIEN(CIPConvert.ToDecimal(ip_obj_id_vi_tri));
        return v_us_dm_vi_tri.strTEN;
    }
    public string mapping_level_by_id(object ip_obj_id_level)
    {
        US_CM_DM_TU_DIEN v_us_dm_vi_tri = new US_CM_DM_TU_DIEN(CIPConvert.ToDecimal(ip_obj_id_level));
        return v_us_dm_vi_tri.strTEN;
    }
    #endregion
    
}